<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/window-property-collector.js"></script>
<script>
var jsTestIsAsync = true;

var frame;
var oldChildWindow;
var newChildWindow;
var propertiesToVerify = [];

function insertExpectedResult(path, expected)
{
    var propertyPath = getPropertyPath(path, path.length);
    propertiesToVerify.push({'property': "oldChildWindow." + propertyPath, 'expected': "newChildWindow." + propertyPath});
}

function runTest()
{
    frame = document.getElementById("test_frame");
    description("Tests property access on a cached DOMWindow after the associated frame is navigated. Test should not crash and properties read from the cached DOMWindow should be identical to properties through the 'current' DOMWindow.");
    oldChildWindow = frame.contentWindow;
    // Have expected results assume that the frame hasn't been closed (=> window.closed = false.)
    collectProperties(document.getElementById("src_frame").contentWindow, false);
    frame.onload = testFrameLoaded;
    frame.src = 'about:blank';
}

function testFrameLoaded()
{
    if (frame) {
        newChildWindow = frame.contentWindow;
        for (var i = 0; i < propertiesToVerify.length; ++i)
            shouldBe(propertiesToVerify[i].property, propertiesToVerify[i].expected);
        finishJSTest();
    }
}
</script>
</head>
<body onload="runTest()">
<iframe id="src_frame"></iframe>
<iframe id="test_frame" src="data:text/plain,"></iframe>
</body>
</html>
